package com.wltt.product.ahuthr.config.schedule;

import com.wltt.product.ahuthr.mapper.AgreementMapper;
import com.wltt.product.ahuthr.model.bo.AgreementWithAttributeBO;
import com.wltt.product.ahuthr.model.po.AgreementPO;
import com.wltt.product.ahuthr.service.RemindService;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.List;

@Configuration
public class AgreementRemindSchedule {

    private static final Logger logger = LogManager.getLogger(AgreementRemindSchedule.class);


    @Resource
    private AgreementMapper agreementMapper;
    @Resource
    private RemindService remindService;

    @Scheduled(cron="0/30 * * * * ?")
    //每天凌晨0点0分0秒时触发执行
//    @Scheduled(cron = "0 0 0 * * ?")
    public void doSchedule() {
        List<AgreementWithAttributeBO> agreementPOList = agreementMapper.queryForRemind();
        for (AgreementWithAttributeBO agreementWithAttributeBO : agreementPOList) {
            remindService.createRemindForAgreement(agreementWithAttributeBO);
        }

    }


}
